package com.info.zhiduoduo.common.exception;

import com.info.zhiduoduo.common.constants.StatusMsg;

import java.util.List;

/**
 * controller接口报错, 会在切片{@code ControllerExceptionAspect}中处理报错日志,并存入{@code logMsg}中.用于显示详情.
 * <p> 最终, 这个Exception会在{@code GlobalExpectionhandler}中统一处理, 返回前端统一的报错状态对象.
 */
public class ApiException extends SmartException {

	/** 记录一些自定义日志信息, 可以通过钉钉,邮件通知开发人员 */
	public String logMsg;

	public ApiException() {
		super();
	}

	public ApiException(String message) {
		super(message);
	}

	public ApiException(String message, Throwable cause) {
		super(message, cause);
	}

	public ApiException(String message, String logMsg, Throwable cause) {
		super(message, cause);
		this.logMsg = logMsg;
	}

	public ApiException(int code, String msg) {
		super(code, msg);
	}

	public ApiException(int code, String message, Throwable cause) {
		super(code, message, cause);
	}

	public ApiException(StatusMsg statusMsg) {
		super(statusMsg);
	}

	public ApiException(StatusMsg statusMsg, Object data) {
		super(statusMsg, data);
	}
	public ApiException(StatusMsg statusMsg, List list) {
		super(statusMsg, list);
	}

	public ApiException(StatusMsg statusMsg, Throwable cause) {
		super(statusMsg, cause);
	}

	public ApiException(StatusMsg statusMsg, String logMsg, Throwable cause) {
		super(statusMsg, cause);
		this.logMsg = logMsg;
	}

	public ApiException(SmartException se) {
		super(se.getMessage(), se.getCause());
		this.state = se.state;
		this.data = se.data;
		this.list = se.list;
	}

	public ApiException(String logMsg, SmartException se) {
		super(se.getMessage(), se);
		this.state = se.state;
		this.data = se.data;
		this.list = se.list;
		this.logMsg = logMsg;
	}
}
